<script type="text/javascript">
$(document).ready(function(){
	$('#Unlockd').click(function(){
		var arr = getCheck();
		$("#morders").val(arr);
		$("#mordertype").val(2);
		$("form#m-form").submit();
		//alert(0);
	});

	$('#Refund').click(function(){
		var arr = getCheck();
		$("#morders").val(arr);
		$("#mordertype").val(3);
		$("form#m-form").submit();
	});
	

	$('#pcheckall').click(function(){
		//alert($(':checkbox').length);
		$('table#p-table :checkbox').each(function(){	
		if($(this).is(':checked'))
			$(this).removeAttr('checked',false);	
		else
			$(this).attr('checked',true);
		});
	});
});

function getCheck(){
	var check = document.getElementsByTagName('input');
	var vals = [];
	var count = 0;
	var str = "";
	for(var i = 0; i < check.length; i++){
		if(check[i].type == 'checkbox' && check[i].checked==true){
			vals[count] = check[i].id + "";
			count++;
			str = str + check[i].id + ",";
		}
	}

	return str;
}

</script>

<?php
$this->breadcrumbs=array(
	'Danh sách ­ Pendding',
); 
?>
<?php if($trangthai == 1){?>
	<h1>Quản lý thông tin pendding 1</h1>
	<form id='m-form' method='post' action ='<?php echo $this->createUrl("dichvu/orderadmin", array('type'=>'pendding1')); ?>'>
	<input id='morders' name='orders' type='hidden'/>
	<label>Ghi chú:</label>
	<input id='comment' name='comment' type='text'/>
	<input id='mordertype' name='ordertype' type='hidden'/>
</form>
<?php }else{?>
	<h1>Quản lý thông tin pendding 2</h1>
	<form id='m-form' method='post' action ='<?php echo $this->createUrl("dichvu/orderadmin", array('type'=>'pendding2')); ?>'>
	<input id='morders' name='orders' type='hidden'/>
	<label>Ghi chú:</label>
	<input id='comment' name='comment' type='text'/>
	<input id='mordertype' name='ordertype' type='hidden'/>
</form>
<?php }?>

<?php $listpendding = Dichvudao::listOrder($trangthai);?>


<div class='full-creen'>
	<?php echo CHtml::button("Unlock", array('id'=>'Unlockd')); ?>
	<?php echo CHtml::button("Refund", array('id'=>'Refund')); ?>
	<?php echo CHtml::link("Export", array('dichvu/exportorder','trangthai'=>$trangthai)); ?>
	<div class='m-paging'> <?php $this->widget('MyPage', array('pages' => $listpendding['pages'])) ;?></div>
</div>
<div class='full-creen'>
	<div class='right-box-item'>
		<h1>Danh sách ­ Pendding</h1>
	<div class='main-content'>
		<table  id='p-table' class='orders'>
		
			<tr class='header-table'>
				<th width='80px'>IMEI</th>
				<th width='80px'>Phone</th>
				<th width='120px'>User</th>
				<th width='200px'>Nhà mạng</th>
				<th width='50px' align='center'>Giá</th>
				<th width='120px'>Ngày order</th>
				<th width='120px'>Ghi chú</th>
				<th width='80px'>
					<a href='#' id='pcheckall' style='color:blue;'>Check All</a>
				</th>
				<th width='100px'>Khác</th>
			</tr>
		<?php
		foreach ( $listpendding['orders'] as $value){
		if($value->sodienthoai != ''){
				echo "<tr class='row-table' style='background: #9DF2EE;'>";				
			}else{
				echo "<tr class='row-table'>";				
			}
			echo "<td '>". $value->noidung. "</td>";
			echo "<td '>". $value->sodienthoai. "</td>";
			echo "<td>". $value->tbuser->username." </td>";
			echo "<td>".$value->tbdichvu->tbnhomdichvu->tennhom." - ". $value->tbdichvu->tendichvu. "</td>";
			echo "<td style='text-align:center'>". $value->gia. "</td>";
			echo "<td>". $value->ngaymua. "</td>";
			echo "<td>". $value->ghichu. "</td>";

			echo "<td>". CHtml::CheckBox($value->id,'', array (
		                                        'checked'=>'checked',
		                                        'value'=>'on',
		                                        )). "</td>";
			echo "<td>". CHtml::link('Trả code', array('dichvu/tracode', 'id'=> $value->id)). "</td>";		                                
			echo "</tr>";
			
		}
		?>
		</table>
	</div>
	</div>
</div>